﻿// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_QC_IQC_ORDER_ITEM
// * CreateDate    : 2012/4/15 0:44:16
// * Creater       : CodeSmith
// * LastChangeDate: 2012/4/15 0:44:16
// * LastChanger   : 2012/4/15 0:44:16
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Chk
{
    /// <summary>
    /// QcIqcOrderItem
    /// </summary>
    public partial class QcIqcOrderItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objQcIqcOrderItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static QcIqcOrderItemEntity GetQcIqcOrderItem(QcIqcOrderItemEntity objQcIqcOrderItemEntity)
        {
            return DataAccess.SelectSingle<QcIqcOrderItemEntity>(objQcIqcOrderItemEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objQcIqcOrderItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertQcIqcOrderItem(QcIqcOrderItemEntity objQcIqcOrderItemEntity)
        {
            return DataAccess.Insert(objQcIqcOrderItemEntity);
        }

        public static bool InsertQcIqcOrderItem(List<QcIqcOrderItemEntity> objQcIqcOrderItemEntityList)
        {
            return DataAccess.Insert(objQcIqcOrderItemEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objQcIqcOrderItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateQcIqcOrderItem(QcIqcOrderItemEntity objQcIqcOrderItemEntity)
        {
            return DataAccess.Update(objQcIqcOrderItemEntity);
        }

        public static bool UpdateQcIqcOrderItem(List<QcIqcOrderItemEntity> objQcIqcOrderItemEntityList)
        {
            return DataAccess.Update<QcIqcOrderItemEntity>(objQcIqcOrderItemEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objQcIqcOrderItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteQcIqcOrderItem(QcIqcOrderItemEntity objQcIqcOrderItemEntity)
        {
            return DataAccess.Delete(objQcIqcOrderItemEntity);
        }

        public static bool DeleteQcIqcOrderItem(List<QcIqcOrderItemEntity> objQcIqcOrderItemEntityList)
        {
            return DataAccess.Delete<QcIqcOrderItemEntity>(objQcIqcOrderItemEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetQcIqcOrderItemAll()
        {
            return DataAccess.SelectAllDataSet<QcIqcOrderItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<QcIqcOrderItemEntity> GetQcIqcOrderItemAllList()
        {
            return DataAccess.SelectAll<QcIqcOrderItemEntity>();
        }
        #endregion

        #region Functions
        public static DataTable GetDtIqcOrderItemByOrderID(string OrderID)
        {
            string sql = @"SELECT QIOI.*,MP.PRODUCT_NAME,MP.PRODUCT_CODE,MP.MATERIAL,MP.DESCRIPTION,QIOI.NG_QTY/QIOI.CHECKED_QTY AS NG_RATE 
                FROM QC_IQC_ORDER_ITEM QIOI
                LEFT JOIN PUR_PURCHASE_ARRIVED_ITEM PPAI ON QIOI.ARRIVED_ITEM_ID=PPAI.ARRIVED_ITEM_ID
                LEFT JOIN PUR_PURCHASE_ORDER_ITEM PPOI ON PPAI.PURCHASE_ITEM_ID=PPOI.PURCHASE_ITEM_ID
                LEFT JOIN MST_PRODUCT MP ON PPOI.PRODUCT_ID=MP.PRODUCT_ID
                WHERE QIOI.REV_QTY!=0 AND QIOI.ORDER_ID='" + OrderID + "' ";
            return DataAccess.SelectDataSet(sql).Tables[0];
        }
        #endregion
    }


}

